import { createRouter, createWebHashHistory } from 'vue-router'
import { basicRoutes, errorRoutes } from './routes/basic'
import createRouterGuard from './helper/guard'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [...basicRoutes, ...errorRoutes],
})

export async function setupRouter(app) {
  createRouterGuard(router)
  app.use(router)
  await router.isReady()
}

export default router
